﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Forex.IB.RealTimeBars.Components
{
    public class ErrorHandler
    {

        public static void WriteException(ForexException ex)
        {
            WriteExceptionToLog(ex);
            SendNotification(ex);
        }

        public static void WriteExceptionToLog(ForexException ex)
        {
            Components.LogFile.LogMessage("Time Called: " + DateTime.Now.ToString());
            Components.LogFile.LogMessage("Error Message: " + ex.Message.ToString());
            Components.LogFile.LogMessage("Stack Trace: " + ex.StackTrace);
        }



        private static void SendNotification(ForexException ex)
        {
            SendEmail notify = new SendEmail();
            notify.Notify(null, null, Common.To, null, null, "Exception occured Forex trading.", ex.Message.ToString(), Common.smtpclient);
        }
    }
}

